package common.common.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import common.common.dao.IUserDao;
import common.common.dao.IUserTypeDao;
import common.common.entity.User;
import common.common.entity.UserType;
import common.common.service.IUserService;

@Service("userService")
@Scope("prototype")
public class UserServiceImpl implements IUserService{
	
	
	@Resource(name="userType")
	UserType userType;
	
	@Resource(name="userTypeDao")
	IUserTypeDao userTypeDao;
	
	@Resource(name="user")
	User loginUser;
	
	@Resource(name="userDao")
	IUserDao userDao;
	
	public boolean isLoginUser(User loginUser){
		
		
		loginUser=(User) userDao.findByExample(loginUser);
		if(loginUser.equals(this.loginUser)){
			return true;
		}
		return false;
	}

	public List<UserType> getAllUserType() {
		List<UserType> typies=new ArrayList<UserType>();
		if(typies.size()>0){
		typies=userTypeDao.findAllUserType();
		return typies;
		}
		return null;
	}

	public UserType findUserTypeById(int userTypeId) {
		UserType userType=new UserType();
		userType=userTypeDao.findById(userTypeId);
		if(userType!=null){
		return userType;
		}
		return null;
	}

	public User user(User user) {
		// TODO Auto-generated method stub
		return null;
	}

	public User findByUserId(int userId) {
		User loginUser=new User();
		loginUser=userDao.findById(userId);
		if(loginUser!=null){
			return loginUser;
		}
		return null;
	}

	public void changePassword(User user, String newPassword) {
		// TODO Auto-generated method stub
		
	}

	public boolean updateRealName(int id, String userName) {
		// TODO Auto-generated method stub
		return false;
	}

	public UserType getUserType() {
		return userType;
	}

	public void setUserType(UserType userType) {
		this.userType = userType;
	}

	public IUserTypeDao getUserTypeDao() {
		return userTypeDao;
	}

	public void setUserTypeDao(IUserTypeDao userTypeDao) {
		this.userTypeDao = userTypeDao;
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}


	
	
	
	

}
